<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>我的</title>
    <link rel="stylesheet" href="../css/mobile.css">
    <script>
        if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) == false) {
            //该页面不是在移动端打开的，
            window.location.href = "/admin/index.html?t=" + new Date().getTime();
        }
    </script>
</head>
<body class="bg-gray">
<div class="works">

</div>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script>

    $.ajax({
        method: "post",
        url: "/admin/user/getUserSession",
        dataType: "JSON",
        success: function (resp) {
            let data = resp.data;

            let works = $(".works");
            works.empty();
            let menus = data.menus;
            for(let i=0;i<menus.length;i++){
                let menu = menus[i];
                let work = $("<div class='work'>" +
                    "<div class='work-title'>"+menu.menuName+"</div>" +
                    "<div class='work-items'></div>" +
                    "</div>");
                let workItems = work.find(".work-items");
                for(let j=0;j<menu.children.length;j++){
                    let child = menu.children[j];

                    let workItem = $("<div class='work-item'>"+child.menuName+"</div>");
                    bindClick(workItem,child);
                    workItems.append(workItem);
                }
                workItems.append("<div style='clear:both;'></div>");
                works.append(work);
            }
        }
    });

    function bindClick(workItem,child){
        workItem.click(function(){
            parent.openFrame(child.menuName,child.url)
        });
    }
</script>
</body>
</html>
